//定义函数格式化数据
function formatNumber(value: any) {
    if (!value) return
    return `${value}`.replace(/(\d{3})(?=\d)/g, '$1,')
    // return `${value}`.replace(/(\d)(?=(\d{3})+$)/g, '$1,')
}

//导出两个格式化功能的函数
export default function useFormat() {
    const numberFormat = (value: any) => formatNumber(value)
    const moneyFormat = (value: any) => `￥${formatNumber(value)}`
    return { numberFormat, moneyFormat }
}


